{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <div class="col-sm-12">
                    <div class="input-group" >
                        <button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">
                            <i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">
                            <li><a  href="javascript:;" class="layuiBtn" data-type="excelIn"><i class="fa fa-external-link"></i> 批量导出</a></li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>

                    <!--图片模板-->
                    <script type="text/html" id="imgTpl">
                        <img src="{{d.oi_good_thumb}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"  />
                    </script>

                    <!--修改状态模板-->
                    <!--<script type="text/html" id="staBar">-->
                    <!--<input type="checkbox" value="{{d.school_id}}"  lay-skin="switch"  lay-text="上架中|已下架" lay-filter="OnOff" {{ d.school_status == 1 ? 'checked' : '' }} >-->
                    <!--</script>-->

                    <!--状态显示模板-->
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("completed/detail")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , loading: true
            ,where: {id:{:session('order_id3')}}
        ,id: 'testReload'
                , cols: [[
            {type: 'checkbox', fixed: 'left'}
            , {type:'numbers', width: 80, title: '序号'}
            , {field: 'oi_good_name', width: 220, title: '商品名称', align: 'center'}
            , {field: 'good_isbn', width: 220, title: 'ISBN', align: 'center'}
            , {field: 'oi_good_thumb', width: 200, title: '商品图片', align: 'center', toolbar: '#imgTpl'}
            , {field: 'spec', width: 120, title: '商品规格', align: 'center'}
            , {field: 'oi_num', width: '', title: '购物数量', align: 'center'}
            , {field: 'price', width: 200, title: '商品价格', align: 'center'}
        ]]
    });
        //批量操作
        var $ = layui.$, active = {
            excelIn: function(){
                //导出Excel
                wk.excelAll(getIds(),$('.layui-input').serialize(),"{:url('excelGood')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['oi_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>